<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <img class="img1" src="img/a.jpg" alt="">

    <script>
        var imgEl = document.querySelector('.img1');
        // 直接通过对象获取属性
        var srcValue = imgEl.src;
        console.log('imgEl.src',srcValue);
        // getAttribute 获取属性 属于dom元素的方法
        var srcValue2 = imgEl.getAttribute('src');
        console.log('getAttribute',srcValue2);
        console.log(imgEl.className, imgEl.getAttribute('class'));
    </script>
</body>
</html>